<template>
  <view class="container" v-if="shade" @click.stop="jumpBtn2()">
    <view class="settime" @click="jumpBtn()">
      {{ count }}
    </view>
    <image :src="url" mode=""></image>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        url: '',
        url2: '',
        count: 5,
        timer: '',
        shade: false,
        qdtkg: 1
      }
    },
    onLoad() {
      this.$http.indexIn().then(res => {
        if (res.code == 200) {
          this.url = res.data.qdt;
          this.url2 = res.data.url;
          this.qdtkg = res.data.qdtkg;
          if (this.qdtkg == 1) {
            uni.switchTab({
              url: '/pages/index/index'
            })
          } else {
            this.timer = setInterval(() => {
              this.count--;
              if (this.count == 0) {
                clearInterval(this.timer);
                uni.switchTab({
                  url: '/pages/index/index'
                })
              }
            }, 1000)
            this.shade = true;
          }
        }
      })
    },
    methods: {
      jumpBtn() {
        // 这里是秒数点击按钮吧 这里清除后  setinterval没了 但是setTimeout 5000ms后给你自动跳的  明白了吗
        clearInterval(this.timer);
        uni.switchTab({
          url: '/pages/index/index'
        })
      },
      jumpBtn2() {
        plus.runtime.openURL(this.url2, function() {
          console.log(res, 123)
        })
      }
    }
  }
</script>

<style lang="less">
  .container {
    width: 100%;
    height: 100vh;

    .settime {
      width: 85rpx;
      height: 85rpx;
      position: fixed;
      background-color: rgba(0, 0, 0, 0.5);
      line-height: 85rpx;
      text-align: center;
      z-index: 9;
      right: 40rpx;
      top: 40rpx;
      font-size: 25rpx;
      border-radius: 50%;
      color: rgba(250, 250, 250, 0.6);
    }

    image {
      width: 100%;
      height: 100vh;
    }
  }
</style>
